package com.ruoyi.bcsettings.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bcsettings.domain.ErpMarketingManager;
import com.ruoyi.bcsettings.service.IErpMarketingManagerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营销经理Controller
 * 
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/bcsettings/manager")
public class ErpMarketingManagerController extends BaseController
{
    @Autowired
    private IErpMarketingManagerService erpMarketingManagerService;

    /**
     * 查询营销经理列表
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpMarketingManager erpMarketingManager)
    {
        startPage();
        List<ErpMarketingManager> list = erpMarketingManagerService.selectErpMarketingManagerList(erpMarketingManager);
        logger.info("查询结果: {}", list);
        return getDataTable(list);
    }

    /**
     * 导出营销经理列表
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:export')")
    @Log(title = "营销经理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpMarketingManager erpMarketingManager)
    {
        List<ErpMarketingManager> list = erpMarketingManagerService.selectErpMarketingManagerList(erpMarketingManager);
        ExcelUtil<ErpMarketingManager> util = new ExcelUtil<ErpMarketingManager>(ErpMarketingManager.class);
        util.exportExcel(response, list, "营销经理数据");
    }

    /**
     * 获取营销经理详细信息
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(erpMarketingManagerService.selectErpMarketingManagerById(id));
    }



    /**
     * 新增营销经理
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:add')")
    @Log(title = "营销经理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpMarketingManager erpMarketingManager)
    {
        return toAjax(erpMarketingManagerService.insertErpMarketingManager(erpMarketingManager));
    }

    /**
     * 修改营销经理
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:edit')")
    @Log(title = "营销经理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpMarketingManager erpMarketingManager)
    {
        return toAjax(erpMarketingManagerService.updateErpMarketingManager(erpMarketingManager));
    }

    /**
     * 删除营销经理
     */
    @PreAuthorize("@ss.hasPermi('bcsettings:manager:remove')")
    @Log(title = "营销经理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(erpMarketingManagerService.deleteErpMarketingManagerByIds(ids));
    }
}
